- 
                Notifications
    
You must be signed in to change notification settings  - Fork 4.9k
 
Add TryGetOwnedMemory ref and tests #27288
Conversation
faa6219    to
    c6f08e5      
    Compare
  
    | } | ||
| 
               | 
          ||
| ownedMemory = default; | ||
| return false; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about:
TOwner owner = readOnlyMemory._object as TOwner;
ownedMemory = owner;
return owner != null;?
| } | ||
| namespace System.Runtime.InteropServices | ||
| { | ||
| using System.Buffers; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't do this in contracts. When this file is auto-generated by the tool at some point again, this will be removed and full names will be used everywhere. Might as well do so now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was having issues getting it compile; didn't know needed a change to coreclr also/first dotnet/coreclr#16455
| return true; | ||
| } | ||
| 
               | 
          ||
| ownedMemory = default; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default => null?
| } | ||
| } | ||
| 
               | 
          ||
| internal class OtherMemoryForTest<T> : OwnedMemory<T> | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does the name start with "Other"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a MemoryForTest this one is just for testing that it doesn't cast to it. Have a preferred name?
| public static bool TryGetOwnedMemory<T, TOwner>(ReadOnlyMemory<T> readOnlyMemory, out TOwner ownedMemory) | ||
| where TOwner : OwnedMemory<T> | ||
| { | ||
| TOwner owner; // Use register for null comparision rahter than byref | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: rahter => rather
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: comparision => comparison
7341065    to
    6c849e3      
    Compare
  
    | 
           Squashed, as I assume it will have to go with a coreclr merge  | 
    
          
 It shouldn't. Nothing in the coreclr change introduced a break with corefx, did it? Assuming not, once that is consumed, this can just be re-run and then merged.  | 
    
| 
           Doesn't it complain there is an implementation with no declaration? Or has that gone now?  | 
    
| 
           Ah... Have to do something with this #27309 (comment)  | 
    
          
 I don't think it's ever complained about that. It definitely complains if there's something specified in the contract that doesn't exist in the implementation, but not the other way around.  | 
    
| 
           K, think worked out how this mirroring works :)  | 
    
| 
           Rebooting  | 
    
| 
           @dotnet-bot test OSX x64 Debug Build  | 
    
a8385b4    to
    dfe131c      
    Compare
  
    | 
           OwnedMemoryBit needs to be removed from the index dotnet/coreclr#16479  | 
    
dfe131c    to
    6cbd1c8      
    Compare
  
    6cbd1c8    to
    f214f42      
    Compare
  
    | 
           NETFX unrelated  | 
    
| 
           @dotnet-bot test NETFX x86 Release Build  | 
    
| 
           @stephentoub should I raise an issue for the NETFX issue or is it just transient networking?  | 
    
          
 Please open an issue. I don't believe we've seen that one fail before, and it's using a loopback server, so really shouldn't have any significant transient networking issues. Thanks.  | 
    
Commit migrated from dotnet/corefx@064a638
Resolves https://github.com/dotnet/corefx/issues/27237